﻿using MediatR;
using UserLicense.Applicationes.Command;
using UserModels;
using UserRepositorys.Intface;

namespace UserLicense.Applicationes.CommandHandler
{
    public class RoleListCommandHandler : IRequestHandler<RoleListCommand, (int totalCount, int pageCount, List<RoleInfoModel> roleList)>
    {
        private readonly IRoleRepository _roleRepository;
        public RoleListCommandHandler(IRoleRepository roleRepository)
        {
            _roleRepository = roleRepository;
        }

        /// <summary>
        /// 显示所有角色信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<(int totalCount, int pageCount, List<RoleInfoModel> roleList)> Handle(RoleListCommand request, CancellationToken cancellationToken)
        {
            var list= await _roleRepository.GetRoleList(request.roleName,request.pageIndex,request.pageSize);
            return (list.totalCount, list.pageCount, list.roleList);
        }
    }
}
